package com.fz.entity;

import com.fz.core.BaseEntity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Random;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

/**
 * <p>
 * 存储系统用户信息
 * </p>
 *
 * @author hyr
 * @since 2025-06-18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 手机号（唯一索引）
     */
    private String phone;

    /**
     * 头像URL
     */
    private String avatar;

    /**
     * 角色(user/admin)
     */
    private String role;

    /**
     * 地址
     */
    private String address;

    /**
     * 年龄
     */
    private Integer age;

    /**
     * 账户余额
     */
    private BigDecimal account;

    /**
     * 性别（1=男，0=女）
     */
    private Integer gender;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 逻辑删除（1=删除）
     */
    private Integer isDeleted;

    /**
     * 冻结状态（1=冻结）
     */
    private Boolean status;

    public User(String phone, String password, String eamil, String role) {
        Random random = new Random();
        int number = 1000000 + random.nextInt(9000000);
        this.password = password;
        this.username = "新用户"+String.valueOf(number)+role;
        this.nickname = "defaultNickName";
        this.avatar = null;
        this.role = "["+role+"]";
        this.address = "defaultAddress";
        this.age = 0;
        this.email=eamil;
        this.account = BigDecimal.ZERO;
        this.status = true;
        this.phone = phone;
    }


    public User(long id, boolean status) {
        super(id);
        this.status = status;
    }

    public User(Long id, String username, String nickyName, Integer gender, Integer age, String phone, String email) {
        super(id);
        this.username = username;
        this.nickname = nickyName;
        this.gender =gender;
        this.phone = phone;
        this.email = email;
        this.age=age;
    }
}
